package com.yupi.yupicturebackend;

import cn.hutool.core.util.StrUtil;
import com.yupi.yupicturebackend.async.AsyncPictureService;
import com.yupi.yupicturebackend.model.entity.Picture;
import com.yupi.yupicturebackend.service.LikeBasedRecommender;
import com.yupi.yupicturebackend.service.PictureService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 @author 边拾柱
 @date 2025/4/6 11:57
 */
@SpringBootTest
public class PictureUnderstand {
    @Resource
    private  PictureService pictureService;

    @Autowired
    private AsyncPictureService asyncPictureService; // 关键：跨Bean调用

    @Test
    public void test() throws InterruptedException {
        List<Picture> list = pictureService.list();
        for (int num = 0; num < list.size(); num++) {
            Picture picture = list.get(num);
            String elements = picture.getElements();
            if (StrUtil.isEmpty(elements)) {
                String url = picture.getUrl();
                Long id = picture.getId();
                System.out.println("图片处理-" + id);
                asyncPictureService.asyncProcess(url,"这张图片里有什么？", id);
//                System.out.println("异步处理中...");
                Thread.sleep(30000);
                System.out.println("处理完成id-" + id);
            }
        }

//        Thread.sleep(2000000);
    }
}
